package com.hangzhou.xyj.net.request;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.hangzhou.xyj.net.request.base.BaseRequest;
import com.hangzhou.xyj.utils.constants.API;

/**
 * Created by yaohuix on 2016/2/24  15:43
 * <p/>
 * 说明：我-分类查询用户 请求
 */
public class GetUserByCatReq extends BaseRequest {

    public static final String BY_CATEGORY_ID = "categoryId";
    public static final String BY_TYPE = "type";
    public static final int TYPE_NORMAL_USER = 1;//普通用户
    public static final int TYPE_FAMOUS_EXPERT = 2;//名家
    public static final int TYPE_FMAOUS_TEAM = 3;//名团
    public static final int TYPE_ACTOR = 4;//演员
    public static final int TYPE_DRAMA_GROUP = 5;//剧团

    /**
     * @param byType      根据什么类型进行查询，接受GetUserByCatReq.ByTypeEnum的枚举
     * @param value       该类型的值
     * @param pageSize    每页的数量
     * @param currentPage 当前页码
     * @return
     * @Description
     * @author yaohuix
     * @date 2016/2/24 15:45
     */
    public GetUserByCatReq(ByTypeEnum byType, int value, int pageSize, int currentPage) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("pageSize", pageSize);
        jsonObject.addProperty("currentPage", currentPage);
        //按type查询，1是普通用户 2是名家 3是名团
        switch (byType) {
            case type:
                jsonObject.addProperty("type", value);
                break;
            case categoryId:
                jsonObject.addProperty("categoryId", value);
                break;
        }
        String jsonStr = new Gson().toJson(jsonObject);
        add("data", jsonStr);
    }


    /**
     * @param type        1 是普通用户 2是名家 3是名团
     * @param categoryId  剧种分类Id
     * @param pageSize    每页项数
     * @param currentPage 当前页数
     * @return
     * @Description
     * @author yaohuix
     * @date 2016/2/24 16:17
     */
    public GetUserByCatReq(int type, int categoryId, int pageSize, int currentPage) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("pageSize", pageSize);
        jsonObject.addProperty("currentPage", currentPage);
        jsonObject.addProperty("categoryId", categoryId);
        jsonObject.addProperty("type", type);
        String jsonStr = new Gson().toJson(jsonObject);
        add("data", jsonStr);
    }

    @Override
    public String getUrl() {
        return API.MY_GET_USER_BY_CATEGORY;
    }

    //查询方式的枚举
    public enum ByTypeEnum {
        categoryId, type
    }
}
